package teshop.data.dao.jpa;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import teshop.data.dao.CustomerDAO;
import teshop.data.domain.Customer;


/**
 * JPA implementation for CustomerDAO
 * 
 * @author Hryhory Lira
 *
 */
@Repository
@Transactional
public class JPACustomerDAO extends JPAGeneralDAO<Customer, Long> implements
		CustomerDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<Customer> getUserByLoginPassword(String login, String password) {
		Query query = manager
				.createQuery("SELECT c FROM Customer c WHERE c.username=?1 AND c.password=?2");
		query.setParameter(1, login);
		query.setParameter(2, password);

		return query.getResultList();
	}

}
